#!/usr/bin/python3
# -*- coding: utf-8 -*-

from urllib.request import urlopen
from urllib.request import urlretrieve

url="http://www.baidu.com/"

response = urlopen(url)
print(response)
print(response.geturl())
print(response.info())

html = response.read()
html = html.decode("utf-8")
print(html)



# 真正的意图，就是把刚才我们获取到的源码直接保存在c:/mybaidu.html中
result = urlretrieve(url, filename="c:/mybaidu.html")
print(result)

# 位置参数
urlretrieve(filename="c:/mybaidu_logo1111.png", url="https://www.baidu.com/img/bd_logo1.png")